<?php

use Diglactic\Breadcrumbs\Breadcrumbs;
use Diglactic\Breadcrumbs\Generator;

Breadcrumbs::for('index', function (Generator $trail) {
    $trail->push('首页', indexUrl());
});
Breadcrumbs::for('search', function (Generator $trail) {
    $trail->push(sprintf('搜索:%s', request()->input('wd')), '/search');
});

Breadcrumbs::for('module', function (Generator $trail, $data) {
    $trail->parent('index');
    $trail->push($data['module']->name);
    //取消单页展示页面链接
    //$trail->push($data['module']->name, $data['module']->url(false));
});

Breadcrumbs::for('classify', function (Generator $trail, $data) {
    $trail->parent('module', $data);
    if (!$data['classify']->id) {
        $trail->push($data['module']->name, $data['module']->url());
    } else {
        $trail->push($data['classify']->name, $data['classify']->url());
    }
});

Breadcrumbs::for('info', function (Generator $trail, $data) {
    $trail->parent('classify', $data);
    $trail->push($data['info']->name, $data['info']->url());
});
